﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using MoveNext.IO.Grf;

namespace MoveNext.IO.Grf
{
    public class GrfFileEntryReader : BaseReader
    {
        private Encoding encoding;

        public GrfFileEntryReader(Stream input)
            : this(input, GrfConst.Encoding)
        {
        }

        public GrfFileEntryReader(Stream input, Encoding encoding)
            : base(input)
        {
        }


        public virtual FileEntry ReadFileEntry()
        {
            FileEntry entry = new FileEntry();
            entry.FullName = this.ReadString();
            entry.CompressedLength = this.ReadInt32();
            entry.CompressedLengthAlligned = this.ReadInt32();
            entry.UncompressedLength = this.ReadInt32();
            entry.Flags = this.ReadByte();
            entry.Offset = this.ReadInt32() + GrfConst.GRF_HEADER_SIZE;

            return entry;
        }
    }
}
